package com.sens.common;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class TimeUtil {
    public static String getCurrentDate() {
        long l = System.currentTimeMillis();
        Date date = new Date(l);
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        return dateFormat.format(date);
    }

    public static Date getCompareDate(int distanceDay) {
        Calendar date = Calendar.getInstance();
        date.setTime(new Date());
        date.set(Calendar.DATE, date.get(Calendar.DATE) + distanceDay);
        return date.getTime();
    }

    public static String getFormatTime(String pattern) {
        return new SimpleDateFormat(pattern).format(new Date());
    }

    public static String getFormatTime(String pattern, Date date) {
        return new SimpleDateFormat(pattern).format(date);
    }
}